<template>
  <div class="divBox">
    <el-card class="box-card">
      <el-form inline size="small" @submit.native.prevent>
        <el-form-item label="关键词：">
          <el-input v-model="listPram.exposureTitle" placeholder="请输入标题" clearable class="selWidth"/>
        </el-form-item>
        <el-form-item label="分类：">
          <el-select v-model="listPram.type" placeholder="分类" clearable style="width: 100%">
            <el-option label="全部" value="0"/>
            <el-option label="通报表扬" value="76"/>
            <el-option label="通报批评" value="77"/>
            <el-option label="情况通报" value="78"/>
<!--            <el-option label="领导讲话" value="84"/>-->
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" size="mini" type="primary" @click="handleSearch">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
        <el-form-item class="el-form-item-align-right">
          <el-button icon="el-icon-circle-plus" size="mini" type="primary" @click="handlerOpenEdit(0)" v-hasPermi="['admin:notice:save']">添加通报曝光</el-button>
        </el-form-item>
      </el-form>
      <el-table :data="listData.list" v-loading="loading" size="mini" :header-cell-style=" {fontWeight:'bold',background:'#f8f8f9',color: '#515a6e',height:'40px'}" border>
        <el-table-column
          prop="id"
          label="ID"
          width="50"
        />
        <el-table-column label="标题" prop="exposureTitle" min-width="200"/>
        <el-table-column
          label="分类"
          min-width="120"
        >
          <template slot-scope="scope">
            <span>{{scope.row.type | typeFilter  }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="是否热门"
          min-width="120"
        >
          <!--  -->
          <template slot-scope="scope" v-if="checkPermi(['admin:notice:update:status'])">
            <el-switch
              v-model="scope.row.isHeat"
              :active-value="1"
              :inactive-value="0"
              active-text="是"
              inactive-text="否"
              @change="onchangeIsShow(scope.row)"
            />
          </template>
        </el-table-column>
        <el-table-column label="排序" prop="sort" min-width="120"/>
        <el-table-column label="创建时间" prop="createTime" min-width="120">
          <template slot-scope="scope">
            <span>{{ scope.row.createTime | filterEmpty }}</span>
          </template>
        </el-table-column>
        <el-table-column label="更新时间" prop="updateTime" min-width="120">
          <template slot-scope="scope">
            <span>{{ scope.row.updateTime | filterEmpty }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="195"  fixed="right" align="center">
          <template slot-scope="scope">
            <el-button icon="el-icon-edit" type="primary" size="mini" @click="handlerOpenEdit(1,scope.row)" v-hasPermi="['admin:notice:info']">编辑</el-button>
            <el-button icon="el-icon-delete" type="danger" size="mini" @click="handlerOpenDel(scope.row)" v-hasPermi="['admin:notice:delete']">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="listPram.page"
        :page-sizes="constants.page.limit"
        :layout="constants.page.layout"
        :total="listData.count"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </el-card>
    <el-dialog
      :visible.sync="editDialogConfig.visible"
      :title="editDialogConfig.isCreate === 0? '创建曝光台公告':'编辑曝光台公告'"
      destroy-on-close
      :close-on-click-modal="false"
      width="1000px"
    >
      <edit
        v-if="editDialogConfig.visible"
        :is-create="editDialogConfig.isCreate"
        :edit-data="editDialogConfig.editData"
        @hideEditDialog="hideEditDialog"
      />
    </el-dialog>
  </div>
</template>

<script>
import * as roleApi from '@/api/role.js'
import * as noticeApi from '@/api/noticeApi.js'
import edit from './edit'
import { checkPermi } from "@/utils/permission";
import * as selfUtil from "@/utils/ZBKJIutil";
import * as categoryApi from "@/api/categoryApi"; // 权限判断函数
export default {
  // name: "index"
  components: { edit },
  filters: {
    typeFilter(status) {
      const statusMap = {
        0: '全部',
        76: '通报表扬',
        77: '通报批评',
        78: '情况通报',
        //84: '领导讲话'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      constants:this.$constants,
      loading:false,
      listData: { list: [] },
      listPram: {
        exposureTitle: '',
        page: 1,
        type: '0',
        limit: this.$constants.page.limit[0]
      },
      editDialogConfig: {
        visible: false,
        isCreate: 0, // 0=创建，1=编辑
        editData: {}
      },
    }
  },
  mounted() {
    this.handleGetNoticeList()
  },
  methods: {
    checkPermi,
    onchangeIsShow(row){
      const _pram = { id: row.id , isHeat: row.isHeat}
      noticeApi.updateStatus( _pram ).then(() => {
        this.$message.success('修改成功')
        this.handleGetNoticeList()
      }).catch(()=>{
        row.status = !row.status
      })
    },

    handleSearch() {
      this.listPram.page = 1
      this.handleGetNoticeList()
    },
    handleSizeChange(val) {
      this.listPram.limit = val
      this.handleGetNoticeList()
    },
    handleCurrentChange(val) {
      this.listPram.page = val
      this.handleGetNoticeList()
    },
    handlerOpenDel(rowData) {
      this.$confirm('确认删除当前数据').then(() => {
        const _pram = { id: rowData.id}
        noticeApi.delRole(_pram).then(data => {
          this.$message.success('删除数据成功')
          this.handleGetNoticeList()
        })
      })
    },

    handleGetNoticeList() {
      noticeApi.getList( this.listPram ).then(data => {
        /*let data = {
          'list':[
            {id:1,title:'瓜州县人民法院关于公布2022年度第一期失信被执行人的公告',content:"原标题：\n" +
              "\n" +
              "市就业服务中心：（引题）\n" +
              "\n" +
              "强化五项举措助就业（主题）\n" +
              "\n" +
              "酒泉日报讯 今年以来,市就业服务中心积极抢抓春节后企业复工复产和就业需求旺盛的有利时机,主动担当、积极作为,通过强化五项举措,助力实现就业“开门红”。\n" +
              "\n" +
              "强化公共就业服务。紧紧围绕市委、市政府工作要求,谋划提出酒泉市“码上就业”公共就业服务平台建设、2023年新能源创业创新大赛、甘肃省高校毕业生等青年群体就业创业暨酒泉市首届“政校企”就业合作对接会和创建全国公共就业创业服务示范城市四项创新工作,全力打造就业服务的“酒泉名片”。目前已研究制定了实施方案,形成了上下联动、聚力攻坚的良好氛围。\n" +
              "\n" +
              "强化创业引领工程。举办了全市“百千万”创业引领工程2023年创业能力提升训练营活动,邀请全国创业创新方面的知名专家教授,对学员进行了为期3天的系统培训。下一步还将采取“走出去学”,进一步提高创业者及就业创业服务工作人员的经营管理能力和创业服务能力。各县市区也先后开展了创业大讲堂、项目推介、创业沙龙等主题系列活动,支持和帮助创业者实现创业。\n" +
              "\n" +
              "强化孵化载体建设。坚持问题导向,科学布局,定向发力,加速推进全市创业就业孵化示范基地实现创建规模“量变”、示范能力“蝶变”和入孵企业“聚变”。至目前,全市累计建成省级创业就业孵化示范基地(园区)16个、市级创业就业孵化示范基地(园区)28个,入孵创业实体1719户,带动就业1.36万人。\n" +
              "\n" +
              "强化金融对接服务。充分发挥创业担保贷款促进创业、稳定就业的作用,创新出台高校毕业生个人创业担保贷款财政全额贴息政策。通过加大政策宣传、优化审批服务,为各类重点群体创业提供了贷款支持。今年1月,全市共为41名个人和5户小微企业发放创业担保贷款1675.5万元,同比增长155%。同时持续做好“陇原惠岗贷”融资业务,强化沟通协调,解决存在问题,加大发放力度,助力企业纾困稳岗。\n" +
              "\n" +
              "强化企业用工保障。联合相关部门开展“2023年春风行动暨就业援助月”服务活动,通过全面组织就业摸排、广泛进行政策宣传、大力推介就业创业项目、精准开展对接服务、密集组织招聘活动、推出系列暖心举措等,全力以赴保障企业用工。至目前,市、县两级共组织各类招聘活动12场次,参加企业403家,提供岗位1万余个,达成意向3000余人。此外,大力开展重点企业“大走访”活动,采取实地走访、问卷调查和座谈交流等形式,认真排查和解决全市园区企业用工短缺问题。 (马涛)",createTimeText:"2023-04-03 09:04",sort:0,isHot:1}
          ]
      }*/

        this.listData = data
     })
    },
    handlerOpenEdit(isCreate, editDate) {
      this.editDialogConfig.editData = editDate
      this.editDialogConfig.isCreate = isCreate
      this.editDialogConfig.visible = true
    },
    hideEditDialog() {
      this.editDialogConfig.visible = false
      this.handleGetNoticeList()
    },
    resetQuery(){
      this.listPram.exposureTitle = '';
      this.handleGetNoticeList()
    },
  }
}
</script>

<style scoped>

</style>
